<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:rich="http://richfaces.org/rich"
	xmlns:a4j="http://richfaces.org/a4j">

<ui:composition template="../templates/hub.xhtml">
	<ui:define name="titre"></ui:define>
	<ui:define name="hub_page">

		<!-- Fonctions javascript. -->
		<script language="javascript">
			function javascriptOnLoad(){
					initSillons();
				}
		</script>

		<!-- Inclusion du bloc de navigation simple. -->
		<ui:include src="../blocs/inc_navigation_message.xhtml" />

		<!-- Pilotage des lignes tableau. -->
		<ui:include src="../blocs/inc_selector.xhtml" />

		<h:form id="sillons_form">
			<h:panelGrid id="sillons_panel_container" width="100%">
				<rich:dataTable value="#{inputDataIhmManaged.lstSillons}"
					var="sillon" style="width:100%"
					rowClasses="rich_datagrid_even_line, rich_datagrid_odd_line"
					iterationStatusVar="it" id="sillons_table" styleClass="stable">

					<f:facet name="noData">
						<h:outputText value="#{msg['msg.info.nodata']}" />
					</f:facet>

					<rich:column style="width:100px; text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['sillon.id']}" />
						</f:facet>
						<h:inputText id="extId" value="#{sillon.extId}" size="10"
							maxlength="15" />
					</rich:column>

					<rich:column style="width:150px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['sillon.train.id']}" />
						</f:facet>
						<h:inputText value="#{sillon.tcmsTrainId}" size="25"
							maxlength="45" id="tcmsTrainId" />
					</rich:column>

					<rich:column style="width:100px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.departure']}" /> / 
							<h:outputText value="#{lbl['common.arrival']}" />
						</f:facet>
						<h:selectOneMenu id="type" value="#{sillon.type}">
							<f:selectItems value="#{repositoryManaged.lstSillonStrictTypes}" />
						</h:selectOneMenu>
					</rich:column>

					<rich:column style="width:170px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['sillon.origin']}" /> / 
							<h:outputText value="#{lbl['sillon.destination']}" />
						</f:facet>
						<h:inputText value="#{sillon.origin}" size="25" maxlength="50"
							id="origin" />
					</rich:column>

					<rich:column style="width:120px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.date']}" />
						</f:facet>
						<rich:calendar inputSize="10" value="#{sillon.movementDate}"
							todayControlMode="hidden" datePattern="dd/MM/yyyy"
							showFooter="false" id="movementDate" />
					</rich:column>

					<rich:column style="width:80px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.time']}" />
						</f:facet>
						<h:inputText value="#{sillon.movementTime}" size="5" maxlength="5"
							id="movementTime" onkeypress="return checkTime(this);" />
					</rich:column>

					<rich:column style="width:100px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['sillon.owner']}" />
						</f:facet>
						<h:inputText value="#{sillon.comment}" size="10" maxlength="20"
							id="owne" />
					</rich:column>

					<rich:column style="width:35px;text-align:center">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.fault.indicator']}" />
						</f:facet>
						<h:graphicImage value="../../imgs/icons/ico_error_20x20.png"
							rendered="#{sillon.errorIndicator}">
						</h:graphicImage>
						<h:graphicImage value="../../imgs/icons/ico_info_20x20.png"
							rendered="#{!sillon.errorIndicator}" />
					</rich:column>

					<rich:column style="text-align:left;">
						<f:facet name="header">
							<h:outputText value="#{lbl['common.message']}" />
						</f:facet>
						<h:outputText value="#{sillon.errorMessage}" />
					</rich:column>

				</rich:dataTable>


				<h:panelGrid columns="3" columnClasses="_left, _center, _right"
					width="100%" border="0">

					<a4j:commandButton onclick="initSillons();"
						value="#{lbl['common.button.erase']}" />

					<h:panelGrid columns="2">
						<h:outputText value="#{lbl['sillon.line.add']}" />
						<a4j:commandLink execute="@form" render="sillons_panel_container"
							action="#{inputDataIhmManaged.addSillon}"
							oncomplete="makeFocusOnField('sillons_form:sillons_table:0:extId');">
							<h:graphicImage value="../../imgs/icons/ico_create.png" />
						</a4j:commandLink>
					</h:panelGrid>

					<a4j:commandButton action="#{inputDataIhmManaged.integrateSillons}"
						value="#{lbl['common.button.validate']}"
						render="sillons_panel_container"
						oncomplete="makeFocusOnField('sillons_form:sillons_table:0:extId');" />

				</h:panelGrid>
			</h:panelGrid>
		</h:form>

		<!-- *************************** -->
		<!-- Initialisation des sillons. -->
		<a4j:jsFunction name="initSillons" execute="@this" immediate="true"
			action="#{inputDataIhmManaged.initSillons}"
			render="sillons_panel_container"
			oncomplete="makeFocusOnField('sillons_form:sillons_table:0:extId');" />
	</ui:define>
</ui:composition>
</html>